<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>订单详情</title>
    <link rel="stylesheet" href="__STATIC_URL__/static/mobile/css/weui.css" />
</head>
<style type="text/css">
    .food img{
        width: 100px;
        height: 100px;
    }
    body{
        background: #F8F8F8;
    }
    .titinfo{
        font-size:14px;
        padding: 10px 15px 0 15px;
    }

    .weui-media-box__desc p{
        line-height: 30px;
    }

    .duihuan{
        position: fixed;
        bottom: 0;
        display: block;
        width: 97%;
        padding: 10px 0;
        background: #3cc360;
        color: #fff;
        border-radius: 5px;
        margin: 5px;
        font-size: 18px;
        text-align: center;
    }
</style>
<body>
<div class="container" id="container">
    <div class="titinfo">
        订单详情
    </div>
    <div class="page preview js_show">
        
        <div class="weui-cells" style="margin-top: 0;">
            <div class="weui-cell">
                <div class="weui-cell__hd food" style="position: relative;margin-right: 10px;">
                    <img src="{$order['goods_img']}">
                </div>
                <div class="weui-cell__bd">
                    <p>{$goods['show']}</p>
                </div>
            </div>
        </div>

        <div class="weui-form-preview">

            <div class="weui-form-preview__bd">
                <div class="weui-form-preview__item">
                    <label class="weui-form-preview__label">卡券名称</label>
                    <span class="weui-form-preview__value">{$order['goods_name']} </span>
                </div>
            </div>

            <div class="weui-form-preview__bd">
                <div class="weui-form-preview__item">
                    <label class="weui-form-preview__label">消费积分</label>
                    <span class="weui-form-preview__value">-{$order['price']}积分</span>
                </div>
            </div>

            <div class="weui-form-preview__bd">
                <div class="weui-form-preview__item">
                    <label class="weui-form-preview__label">手机号</label>
                    <span class="weui-form-preview__value"> {$order['phone']}</span>
                </div>
            </div>

            <div class="weui-form-preview__bd">
                <div class="weui-form-preview__item">
                    <label class="weui-form-preview__label">卡号</label>
                    <span class="weui-form-preview__value"> {$order['get_code']}</span>
                </div>
            </div>

        </div>

        <div class="">
            {eq name="order.statu" value="2"}
                <a class="duihuan clickself" onclick="" href="javascript:;" data-url="{:url('carduser/getopencard')}" data-cardcode="{$order['get_code']}" data-cardid="{$order['goods_card_id']}">打开使用</a>
            {else/}
                <a class="duihuan clickself" onclick="" href="javascript:;" data-url="{:url('cardget/getaddcardshop')}" data-orderid="{$order['id']}" data-cardid="{$order['goods_card_id']}">重新领取</a>
            {/eq}
        </div>

    </div>





</div>
</body>
<script src="__STATIC_URL__/static/jquery/3.2.1/jquery.min.js"></script>
<script src="https://res.wx.qq.com/open/libs/weuijs/1.0.0/weui.min.js"></script>
<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script type="text/javascript">
    $(function () {
//        console.log(window.location.pathname/window.location.protocol/window.location.host);

        $(".clickself").click(function () {
            var cardid = $(this).attr("data-cardid");
            var url = $(this).attr("data-url");
            var orderid = $(this).attr("data-orderid");
            var cardcode = $(this).attr("data-cardcode");
            $.post({
                url: url,
                data: {
                    card_id: cardid,
                    url: window.location.href,

                    {eq name="order.statu" value="2"}
                        cardcode:cardcode
                    {else}
                        orderid: orderid
                    {/eq}
                },
                success: function (data) {
                    console.log(data);
                    wx.config({
                        debug: false,
                        appId: data.jssdk.appId,
                        timestamp: data.jssdk.timestamp,
                        nonceStr: data.jssdk.nonceStr,
                        signature: data.jssdk.signature,
                        jsApiList: [
                            {eq name="order.statu" value="2"}
                            'openCard',
                            {else}
                            'addCard',
                            {/eq}
                        ]
                    });
                    wx.ready(function () {
                        {eq name="order.statu" value="2"}
                        wx.openCard({
                            cardList: [
                                data.card
                            ]
                        });
                        {else}
                        wx.addCard({
                            cardList: [
                                {
                                    cardId: cardid,
                                    cardExt: data.card.ext
                                }
                            ]
                        });
                        {/eq}
                    });
                }
            })
        })
    });
</script>
</html>
